using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using HengTong.Model._Admin;
using HengTong.Model;


namespace HengTong.ViewModel._Admin.SysDataPrivilegeVms
{
    public partial class SysDataPrivilegeListVm : BasePagedListVM<SysDataPrivilegeView, SysDataPrivilegeSearcher>
    {

        protected override IEnumerable<IGridColumn<SysDataPrivilegeView>> InitGridHeader()
        {
            return new List<GridColumn<SysDataPrivilegeView>>{
                this.MakeGridHeader(x => x.EntityType),
                this.MakeGridHeader(x => x.TargetType),
                this.MakeGridHeader(x => x.Scope),
                this.MakeGridHeader(x => x.CustomCondition),
                this.MakeGridHeader(x => x.Priority),
                this.MakeGridHeader(x => x.IsEnabled),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<SysDataPrivilegeView> GetSearchQuery()
        {
            var query = DC.Set<SysDataPrivilege>()
                .CheckContain(Searcher.EntityType, x=>x.EntityType)
                .CheckEqual(Searcher.TargetType, x=>x.TargetType)
                .CheckEqual(Searcher.Scope, x=>x.Scope)
                .CheckEqual(Searcher.IsEnabled, x=>x.IsEnabled)
                .Select(x => new SysDataPrivilegeView
                {
				    ID = x.ID,
                    EntityType = x.EntityType,
                    TargetType = x.TargetType,
                    Scope = x.Scope,
                    CustomCondition = x.CustomCondition,
                    Priority = x.Priority,
                    IsEnabled = x.IsEnabled,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class SysDataPrivilegeView : SysDataPrivilege{

    }
}
